home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mnsbm.zip / WORDS.CB < prev    next >
Text File  |  1989-10-31  |  8KB  |  355 lines

  1.  
  2. /*     Program Name: words.m                                                                 */
  3. /*     Author: James M. Rodriguez                                                          */
  4. /*     Solution Systems Inc.                                                                 */
  5.  
  6. /*     This macro was designed to employ some rudimentary word-processing      */
  7. /*     functions in Brief.    It creates a menu from WORDS.MNU which must         */
  8. /*     be located in your HELP directory.    The macro INCLUDEs an EPSON.H         */
  9. /*     which defines the escape codes for your printers functions.              */
  10. /*     Text must be in a marked block.    NO line markings are permitted.         */
  11.  
  12. #include "dialog.h"
  13. #include "epson.cb"
  14.  
  15. words (...)
  16. {
  17.     extern temp_str;
  18.  
  19.     int sys_buff;
  20.  
  21.     temp_str = "NULL";
  22.     _process_menu (40, 17, 70, 6, "WP Functions", "  ─┘ to select", "words.mnu", NULL, "_words_select");
  23.  
  24.     if (temp_str != "NULL")
  25.         {
  26.         execute_macro (temp_str);
  27.         }
  28.     raise_anchor ();
  29. }
  30.  
  31. _words_select (...)
  32. {
  33.     int event_type,
  34.          menu_line;
  35.  
  36.     get_parm (0, event_type);
  37.     switch (event_type)
  38.         {
  39.         case DIALOG_ESCAPE:
  40.             temp_str = "NULL";
  41.         case DIALOG_GREY_MINUS:
  42.             temp_str = "NULL";
  43.         case DIALOG_PICK_MENU:
  44.             {
  45.             get_parm (2, temp_str);
  46.             temp_str = trim (substr (temp_str, index (temp_str, ";") + 1, 12));
  47.             exit ();
  48.             }
  49.         case DIALOG_ALTER_MENU:
  50.             {
  51.             get_parm (2, temp_str);
  52.             message ("%s", substr (temp_str, index (temp_str, "|") + 1));
  53.             }
  54.         }
  55.     returns TRUE;
  56. }
  57.  
  58. _bold (...)
  59. {
  60.     int start_line,
  61.          start_col,
  62.          end_line,
  63.          end_col;
  64.  
  65.     if (0 < inq_marked (start_line, start_col, end_line, end_col))
  66.         {
  67.         save_position ();
  68.         move_abs (start_line, start_col);
  69.         insert (BOLD_ON_CHAR);
  70.         if (start_line == end_line)
  71.             move_abs (end_line, 2 + end_col);
  72.         else
  73.             move_abs (end_line, 1 + end_col);
  74.         insert (BOLD_OFF_CHAR);
  75.         restore_position ();
  76.         }
  77.     else
  78.         message ("NO MARKED BLOCK PROCESSS-ABORTED");
  79. }
  80.  
  81. _ital (...)
  82. {
  83.     int start_line,
  84.          start_col,
  85.          end_line,
  86.          end_col;
  87.  
  88.     save_position ();
  89.     if (0 < inq_marked (start_line, start_col, end_line, end_col))
  90.         {
  91.         save_position ();
  92.         move_abs (start_line, start_col);
  93.         insert (ITALIC_ON_CHAR);
  94.         if (start_line == end_line)
  95.             move_abs (end_line, 2 + end_col);
  96.         else
  97.             move_abs (end_line, 1 + end_col);
  98.         insert (ITALIC_OFF_CHAR);
  99.         restore_position ();
  100.         }
  101.     else
  102.         message ("NO MARKED BLOCK PROCESSS-ABORTED");
  103. }
  104.  
  105. _empha (...)
  106. {
  107.     int start_line,
  108.          start_col,
  109.          end_line,
  110.          end_col;
  111.  
  112.     save_position ();
  113.     if (0 < inq_marked (start_line, start_col, end_line, end_col))
  114.         {
  115.         save_position ();
  116.         move_abs (start_line, start_col);
  117.         insert (EMPHASIZE_ON_CHAR);
  118.         if (start_line == end_line)
  119.             move_abs (end_line, 2 + end_col);
  120.         else
  121.             move_abs (end_line, 1 + end_col);
  122.         insert (EMPHASIZE_OFF_CHAR);
  123.         restore_position ();
  124.         }
  125.     else
  126.         message ("NO MARKED BLOCK PROCESSS-ABORTED");
  127. }
  128.  
  129. _wide (...)
  130. {
  131.     int start_line,
  132.          start_col,
  133.          end_line,
  134.          end_col,
  135.          bold_line;
  136.  
  137.     save_position ();
  138.     if (0 < inq_marked (start_line, start_col, end_line, end_col))
  139.         {
  140.         save_position ();
  141.         bold_line = start_line;
  142.         if (start_line == end_line)
  143.             {
  144.             move_abs (bold_line, start_col);
  145.             insert (WIDE_ON_CHAR);
  146.             if (bold_line == end_line)
  147.                 move_abs (bold_line, 2 + end_col);
  148.             else
  149.                 move_abs (bold_line, 1 + end_col);
  150.             insert (WIDE_OFF_CHAR);
  151.             bold_line = end_line;
  152.             }
  153.         while (end_line != bold_line)
  154.             {
  155.             move_abs (bold_line, start_col);
  156.             insert (WIDE_ON_CHAR);
  157.             if (bold_line == end_line)
  158.                 move_abs (bold_line, 2 + end_col);
  159.             else
  160.                 move_abs (bold_line, 1 - end_of_line ());
  161.             insert (WIDE_OFF_CHAR);
  162.             ++bold_line;
  163.             }
  164.         restore_position ();
  165.         }
  166.     else
  167.         message ("NO MARKED BLOCK PROCESSS-ABORTED");
  168. }
  169.  
  170. _und (...)
  171. {
  172.     int start_line,
  173.          start_col,
  174.          end_line,
  175.          end_col;
  176.  
  177.     save_position ();
  178.     if (0 < inq_marked (start_line, start_col, end_line, end_col))
  179.         {
  180.         save_position ();
  181.         move_abs (start_line, start_col);
  182.         insert (UNDERLINE_ON_CHAR);
  183.         if (start_line == end_line)
  184.             move_abs (end_line, 2 + end_col);
  185.         else
  186.             move_abs (end_line, 1 + end_col);
  187.         insert (UNDERLINE_OFF_CHAR);
  188.         restore_position ();
  189.         }
  190.     else
  191.         message ("NO MARKED BLOCK PROCESSS-ABORTED");
  192. }
  193.  
  194. _conden (...)
  195. {
  196.     int start_line,
  197.          start_col,
  198.          end_line,
  199.          end_col;
  200.  
  201.     save_position ();
  202.     if (0 < inq_marked (start_line, start_col, end_line, end_col))
  203.         {
  204.         save_position ();
  205.         move_abs (start_line, start_col);
  206.         insert (CONDENSED_ON_CHAR);
  207.         if (start_line == end_line)
  208.             move_abs (end_line, 2 + end_col);
  209.         else
  210.             move_abs (end_line, 1 + end_col);
  211.         insert (CONDENSED_OFF_CHAR);
  212.         restore_position ();
  213.         }
  214.     else
  215.         message ("NO MARKED BLOCK PROCESSS-ABORTED");
  216. }
  217.  
  218. _paginate (...)
  219. {
  220.     int flag,
  221.          head_space,
  222.          line_count;
  223.  
  224.     flag = 0;
  225.     save_position ();
  226.     end_of_buffer ();
  227.     inq_position (line_count, NULL);
  228.     top_of_buffer ();
  229.     translate (HEADER_SPACE, "", 1, 1, 0, 1);
  230.     top_of_buffer ();
  231.     insert (HEADER_SPACE);
  232.     flag = line_count / LINES;
  233.     while (0 < flag)
  234.         {
  235.         goto_line (LINES * flag);
  236.         --flag;
  237.         insert (HEADER_SPACE);
  238.         }
  239.     restore_position ();
  240. }
  241. _strip (...)
  242. {
  243.     top_of_buffer ();
  244.     translate (BOLD_ON_CHAR, "", 1, 1, 0, 1);
  245.     translate (BOLD_OFF_CHAR, "", 1, 1, 0, 1);
  246.     translate (ITALIC_ON_CHAR, "", 1, 1, 0, 1);
  247.     translate (ITALIC_OFF_CHAR, "", 1, 1, 0, 1);
  248.     translate (HEADER_SPACE, "", 1, 1, 0, 1);
  249.     translate (EMPHASIZE_ON_CHAR, "", 1, 1, 0, 1);
  250.     translate (EMPHASIZE_OFF_CHAR, "", 1, 1, 0, 1);
  251.     translate (WIDE_ON_CHAR, "", 1, 1, 0, 1);
  252.     translate (WIDE_OFF_CHAR, "", 1, 1, 0, 1);
  253.     translate (UNDERLINE_ON_CHAR, "", 1, 1, 0, 1);
  254.     translate (UNDERLINE_OFF_CHAR, "", 1, 1, 0, 1);
  255.     translate (CONDENSED_ON_CHAR, "", 1, 1, 0, 1);
  256.     translate (CONDENSED_OFF_CHAR, "", 1, 1, 0, 1);
  257. }
  258.  
  259. _printer (...)
  260. {
  261.     string last_char,
  262.              tab_reply,
  263.              quality_char,
  264.              quality_on_char,
  265.              quality_off_char,
  266.              pitch_char,
  267.              pitch_on_char,
  268.              pitch_off_char;
  269.  
  270.     int old_buffer,
  271.          temp_buffer,
  272.          tab_stop;
  273.  
  274.     old_buffer = inq_buffer ();
  275.     set_buffer (old_buffer);
  276.     attach_buffer (old_buffer);
  277.     inq_names (last_char, NULL, NULL);
  278.     while (0 < search_string ("\\", last_char, 1, 0))
  279.         {
  280.         last_char = substr (last_char, 1 + search_string ("\\", last_char, 1, 0));
  281.         message ("%s", last_char);
  282.         }
  283.     tab_stop = search_string (".", last_char, NULL, 1, 0);
  284.     last_char = substr (last_char, 1, tab_stop - 1);
  285.     last_char += ".WPF";
  286.     del (last_char);
  287.     temp_buffer = create_buffer (last_char, last_char);
  288.     set_buffer (old_buffer);
  289.     attach_buffer (old_buffer);
  290.     top_of_buffer ();
  291.     drop_anchor (3);
  292.     end_of_buffer ();
  293.     copy ();
  294.     set_buffer (temp_buffer);
  295.     attach_buffer (temp_buffer);
  296.     top_of_buffer ();
  297.     drop_anchor (3);
  298.     end_of_buffer ();
  299.     delete_block ();
  300.     top_of_buffer ();
  301.     paste ();
  302.     top_of_buffer ();
  303.     refresh ();
  304.     get_parm (0, pitch_char, "Enter pitch [10, 12, 15]:  ", 4, PITCH);
  305.     pitch_char = substr (pitch_char, 1, 2);
  306.  
  307.     switch (pitch_char)
  308.         {
  309.         case "10":
  310.             pitch_on_char = TEN_PT_ON;
  311.         case "12":
  312.             pitch_on_char = TWELVE_PT_ON;
  313.         case "15":
  314.             pitch_on_char = FIFTEEN_PT_ON;
  315.         }
  316.     get_parm (0, quality_char, "Enter Type Quality [DRAFT, LQ]:  ", 5, QUALITY);
  317.     quality_char = upper (substr (quality_char, 1, 2));
  318.  
  319.     switch (quality_char)
  320.         {
  321.  
  322.         case "DR":
  323.             quality_on_char = DRAFT_ON;
  324.         case "LQ":
  325.             quality_on_char = LQ_ON;
  326.  
  327.         }
  328.  
  329.     insert (quality_on_char);
  330.     insert (pitch_on_char);
  331.     end_of_buffer ();
  332.     insert (PRN_RESET);
  333.     top_of_buffer ();
  334.     translate (BOLD_ON_CHAR, BOLD_ON, 1, 1, 0, 1);
  335.     translate (BOLD_OFF_CHAR, BOLD_OFF, 1, 1, 0, 1);
  336.     translate (ITALIC_ON_CHAR, ITALIC_ON, 1, 1, 0, 1);
  337.     translate (ITALIC_OFF_CHAR, ITALIC_OFF, 1, 1, 0, 1);
  338.     translate (EMPHASIZE_ON_CHAR, EMPHASIZE_ON, 1, 1, 0, 1);
  339.     translate (EMPHASIZE_OFF_CHAR, EMPHASIZE_OFF, 1, 1, 0, 1);
  340.     translate (WIDE_ON_CHAR, WIDE_ON, 1, 1, 0, 1);
  341.     translate (WIDE_OFF_CHAR, WIDE_OFF, 1, 1, 0, 1);
  342.     translate (UNDERLINE_ON_CHAR, UNDERLINE_ON, 1, 1, 0, 1);
  343.     translate (UNDERLINE_OFF_CHAR, UNDERLINE_OFF, 1, 1, 0, 1);
  344.     translate (CONDENSED_ON_CHAR, CONDENSED_ON, 1, 1, 0, 1);
  345.     translate (CONDENSED_OFF_CHAR, CONDENSED_OFF, 1, 1, 0, 1);
  346.     write_buffer ();
  347.     set_buffer (old_buffer);
  348.     attach_buf